<?php

declare(strict_types=1);

namespace app\common\validate;

use think\Validate;

class DingTalk extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'title' => 'require|string',
        'content' => 'require|string',
        'url' => 'require|string',
        'userList' => 'require|array',
        'departmentList' => 'array',
        'coverImage' => 'string',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'title.require' => '标题不能为空',
        'title.string' => '标题必须是字符串',
        'content.require' => '内容不能为空',
        'content.string' => '内容必须是字符串',
        'url.require' => '链接不能为空',
        'url.string' => '链接必须是字符串',
        'userList.require' => '用户列表不能为空',
        'userList.array' => '用户列表必须是数组',
        'departmentList.array' => '部门列表必须是数组',
        'coverImage.string' => '封面图片必须是字符串',
    ];

    protected $scene = [
        'SendActionCardJobNotificationMessage' => ['title', 'content', 'url', 'userList', 'departmentList', 'coverImage'],
        'SendTextJobNotificationMessage' => ['content', 'userList'],
    ];
}
